// pages/my/logistics/logistics.js
var app = getApp()
Page({
  data: {
    logisticsType: 1,
    logisticsList: [
    // {
    //   info: "货已到店，本次配送完成，感谢您此次购买，祝您生活愉快！",
    //   time:"2018-07-28   12:00",
    //   isNew:true,
    //    isLast: false
    // },{
    //     info: "新大洲货运已出发，请内心等待.联系电话18327345678！",
    //     time: "2018-07-28   12:00",
    //     isNew: false,
    //     isLast: false
    // },{
    //     info: "收到",
    //     time: "2018-07-28   12:00",
    //     isNew: false,
    //     isLast:true
    // }
    ]
  },
  onLoad: function(options) {
    // let company = options.company
    let company = ''
    // let expressNo = options.expressNo
    let expressNo = ''
    this.getLogisticInfo(company,expressNo)
    var logisticsType=0;
      if(options.type==1){
        logisticsType=1;
        wx.setNavigationBarTitle({
          title: '物流详情',
        })
      }else{
        wx.setNavigationBarTitle({
          title: '配送详情',
        })
      }
      this.setData({
        logisticsType: logisticsType,
        company,
        expressNo
      })
  },
  getLogisticInfo(logistics_company,expressNo){
    let data = {
      logistics_company,
      expressNo
    }
    let logisticsList = []
    app.request('wx_app/after/sale/logistics/info',data,'GET').then(res=>{
      console.log(res)
      let list = res.data.detail
      list.forEach((item,index)=>{
        if (index==0) {
          logisticsList.push({
            info:item.logisticsDesc,
            time:item.logisticsTime,
            isNew:true
          })
        }else if (index==list.length-1) {
          logisticsList.push({
            info:item.logisticsDesc,
            time:item.logisticsTime,
            isLast:true
          })
        }else{
          logisticsList.push({
            info:item.logisticsDesc,
            time:item.logisticsTime
          })
        }
      })
      this.setData({
        logisticsList
      })
    })
  }
})